import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserStakingsVO, UserStakingsForm, UserStakingsQuery } from '@/api/business/userStakings/types';

/**
 * 查询用户质押记录列表
 * @param query
 * @returns {*}
 */

export const listUserStakings = (query?: UserStakingsQuery): AxiosPromise<UserStakingsVO[]> => {
  return request({
    url: '/business/userStakings/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户质押记录详细
 * @param id
 */
export const getUserStakings = (id: string | number): AxiosPromise<UserStakingsVO> => {
  return request({
    url: '/business/userStakings/' + id,
    method: 'get'
  });
};

/**
 * 新增用户质押记录
 * @param data
 */
export const addUserStakings = (data: UserStakingsForm) => {
  return request({
    url: '/business/userStakings',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户质押记录
 * @param data
 */
export const updateUserStakings = (data: UserStakingsForm) => {
  return request({
    url: '/business/userStakings',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户质押记录
 * @param id
 */
export const delUserStakings = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/userStakings/' + id,
    method: 'delete'
  });
};

export const processRebates = (dateTime: string | number) => {
  return request({
    url: '/business/userStakings/processRebates',
    method: 'get',
    params:{
      dateTime
    }
  });
};
